package org.study.neo4j.boot.repository;

import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.query.Param;
import org.study.neo4j.boot.model.Student;

import java.util.List;

/**
 * 作用描述
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2025年04月09日
 */
public interface StudentRepository extends Neo4jRepository<Student, Long> {
    List<Student> findByName(String name);

    @Query("MATCH (s:Student)-[:ENROLLED_IN]->(c:Course) WHERE c.code = $courseCode RETURN s")
    List<Student> findByCourseCode(@Param("courseCode") String courseCode);

    @Query("MATCH (s:Student)-[:TAUGHT_BY]->(t:Teacher) WHERE t.name = $teacherName RETURN s")
    List<Student> findByTeacherName(@Param("teacherName") String teacherName);
}
